#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2024/2/3 13:26
# @Author : Yoin

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2024/2/3 11:44
# @Author : Yoin
import pymysql

# 1.连接mysql
# 1.1建立连接
conn = pymysql.connect(host="127.0.0.1", port=3306, user="root", password="root", charset="utf8", db="db1")
# 1.2 创建与数据库传送接收数据的介质
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

# 2.发送指令

sql = "delete  from admin where id = %s"
cursor.execute(sql, [2, ])  # 第二个参数必须是列表
# 2.2传指令到数据库
conn.commit()
# 3.关闭连接
cursor.close()
conn.close()
